package com.ydgk.service;

import com.ydgk.bean.Order;
import com.ydgk.bean.User;
import com.ydgk.dao.OrderDao;
import com.ydgk.dao.UserDao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class OrderService {
    OrderDao orderDao=new OrderDao();
    UserDao userDao=new UserDao();
    public Map AdminSearch(String orderform, Integer pageNumber){
        int maxPage = orderDao.adminSearchMaxPage(orderform);
        if(pageNumber > maxPage){
            pageNumber = maxPage;
        }
        if(pageNumber < 1){
            pageNumber = 1;
        }
        String pageCode = orderDao.genPagination
                ("OrderServlet.action",maxPage,pageNumber,"flag=findOrder&orderform="+(orderform==null?"":orderform));

        List<Order> orderList = orderDao.adminSearch(orderform , pageNumber);

        HashMap map = new HashMap();
        map.put("pageCode",pageCode);
        map.put("orderList",orderList);
        return map;

    }
    public int updateById(Order order){
       return orderDao.updateById(order);
    }
    public int deleteById(int id){
        return orderDao.deleteById(id);
    }
}
